package com.yiyuan.app.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.guaike.core.mybatis.plugins.BaseDAO;
import com.yiyuan.app.entity.enums.UserStatusEnum;
import com.yiyuan.app.entity.po.UAppUserPO;
import com.yiyuan.app.mapper.UAppUserMapper;
import org.springframework.stereotype.Repository;

@Repository
public class UAppUserDAO extends BaseDAO<UAppUserMapper, UAppUserPO> {

    public UAppUserPO findNoCancelWx(String openId) {
        LambdaQueryWrapper<UAppUserPO> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(UAppUserPO::getOpenid, openId);
        queryWrapper.ne(UAppUserPO::getStatus, UserStatusEnum.cancel.getCode());
        return getBaseMapper().selectOne(queryWrapper);
    }

    public UAppUserPO findNoCancelIos(String iosSub) {
        LambdaQueryWrapper<UAppUserPO> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(UAppUserPO::getIosSub, iosSub);
        queryWrapper.ne(UAppUserPO::getStatus, UserStatusEnum.cancel.getCode());
        return getBaseMapper().selectOne(queryWrapper);
    }
}
